{# SPDX-License-Identifier: Apache-2.0 -#}

{% extends "admin/base.html" %}

{% import "admin/utils/pagination.html" as pagination %}

{% block title %}{{ ip_address }}{% endblock %}

{% block breadcrumb %}
  <li class="breadcrumb-item"><a href="{{ request.route_path('admin.ip_address.list') }}">IP Addresses</a></li>
  <li class="breadcrumb-item active">{{ ip_address }}</li>
{% endblock %}

{% block content %}
<div class="card">
  <div class="card-header">
    <h3 class="card-title"><code>IpAddress</code> Record</h3>
  </div> <!-- /.card-header -->

  <div class="card-body">
    <dl class="row">
      <dt class="col-sm-4">IP Address:</dt>
      <dd class="col-sm-8">{{ ip_address.ip_address }}</dd>

      <dt class="col-sm-4">IP Address ID:</dt>
      <dd class="col-sm-8">{{ ip_address.ip_address.id }}</dd>

      <dt class="col-sm-4">Hashed IP Address:</dt>
      <dd class="col-sm-8">{{ ip_address.hashed_ip_address }}</dd>

      <dt class="col-sm-4">Last Seen Geo IP Info:</dt>
      <dd class="col-sm-8">{{ ip_address.geoip_info }}</dd>

      <dt class="col-sm-4">Banned?</dt>
      <dd class="col-sm-8">{% if ip_address.is_banned %}<i class="fa fa-check text-red"></i>{% else %}False{% endif %}</dd>

      <dt class="col-sm-4">Ban Date:</dt>
      <dd class="col-sm-8">{{ ip_address.ban_date }}</dd>

      <dt class="col-sm-4">Ban Reason:</dt>
      <dd class="col-sm-8">{{ ip_address.ban_reason.value }}</dd>
    </dl>
  </div> <!-- /.card-body -->
</div> <!-- /.card -->

  <div class="card">
    <div class="card-header with-border">
      <h3 class="card-title">Unique logins</h3>
    </div>

  <div class="card-body">
    {% if unique_logins %}
    <div class="table-responsive p-0">
      <table class="table table-hover" id="pending-oidc-publishers">
        <thead>
          <tr>
            <th scope="col">Created</th>
            <th scope="col">User</th>
            <th scope="col">Status</th>
            <th scope="col">Device Information</th>
          </tr>
        </thead>
        <tbody>
          {% for login in unique_logins %}
          <tr>
            <td>{{ login.created }}</td>
            <td><a href="{{ request.route_path('admin.user.detail', username=login.user.username ) }}">{{ login.user.username }}</a></td>
            <td>{{ login.status.value }}</td>
            <td>{{ login.device_information }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
    {% else %}
    No known logins.
    {% endif %}
  </div> <!-- /.card-body -->
</div> <!-- /.card -->
{% endblock %}
